Fixes to sub 4GB allocator
authoriap10@freefall.cl.cam.ac.uk <iap10@freefall.cl.cam.ac.uk>
Thu, 8 Sep 2005 17:35:44 +0000 (17:35 +0000)
committeriap10@freefall.cl.cam.ac.uk <iap10@freefall.cl.cam.ac.uk>
Thu, 8 Sep 2005 17:35:44 +0000 (17:35 +0000)
Signed-off-by: ian@xensource.com
xen/common/memory.c
xen/include/asm-x86/page.h

index a744272539398b1a3558a010c8c5838ee0914f45..45e9cc6852804d5717ce00ea8a2833f8b9a2bd9e 100644 (file)
@@ -154,7 +154,8 @@ long do_memory_op(int cmd, void *arg)
         reservation.nr_extents -= start_extent;
 
         if ( (reservation.address_bits != 0) &&
-             (reservation.address_bits < (get_order(max_page) + PAGE_SHIFT)) )
+             (reservation.address_bits <
+              (get_order_from_pages(max_page) + PAGE_SHIFT)) )
         {
             if ( reservation.address_bits < 31 )
                 return -ENOMEM;
index 71edad153029a55e96bc5f8ea433db2829782813..2473b8cbf34911e080a225c525b4c5adc35fb9d8 100644 (file)
@@ -280,7 +280,7 @@ extern void paging_init(void);
 
 #ifndef __ASSEMBLY__
 
-static __inline__ int get_order(unsigned long size)
+static inline int get_order_from_bytes(physaddr_t size)
 {
     int order;
     size = (size-1) >> PAGE_SHIFT;
@@ -289,6 +289,17 @@ static __inline__ int get_order(unsigned long size)
     return order;
 }
 
+static inline int get_order_from_pages(unsigned long nr_pages)
+{
+    int order;
+    nr_pages--;
+    for ( order = 0; nr_pages; order++ )
+        nr_pages >>= 1;
+    return order;
+}
+
+#define get_order(s) get_order_from_bytes(s)
+
 /* Allocator functions for Xen pagetables. */
 struct pfn_info *alloc_xen_pagetable(void);
 void free_xen_pagetable(struct pfn_info *pg);